<template>
    <div class="news_detail" v-wechat-title="detail.title">
        <div class="banner">
            <div class="shadow">
                <span class="tit">新闻资讯</span>
                <span class="dec">小二哥科技官方发布的最新动态或消息，为您提供关于相关行业的第一手资讯。</span>
            </div>
        </div>

        <div class="content">
            <div class="left">
                <div class="breadcrumb">
                    <router-link to="/">首页</router-link>
                    <span>></span>
                    <router-link to="/news">新闻中心</router-link>
                    <span>></span>
                    <router-link class="active" :to="`/news/${$route.params.id}`">{{detail.title}}</router-link>
                </div>
                <span class="tit">{{detail.title}}</span>
                <span class="dec">{{detail.time}}<span style="display:inline-block;margin-left:20px;">小二哥科技有限公司</span></span>

                <div class="html_wrap" v-html="removeHtmlStyle(detail.content)"></div>

                <div class="pagination">
                    <div>
                        <span v-if="newsList[detail.id-1]" @click="$router.push(`/news/${newsList[detail.id-1].id}`)">
                            <i class="el-icon-arrow-left"></i>
                            上一篇：{{newsList[detail.id-1].title}}
                        </span>
                    </div>
                    
                    <div>
                        <span v-if="newsList[detail.id+1]" @click="$router.push(`/news/${newsList[detail.id+1].id}`)">
                            下一篇：{{newsList[detail.id+1].title}}
                            <i class="el-icon-arrow-right"></i>
                        </span>
                    </div>
                    
                </div>
            </div>
            <div class="right">
                <span class="tit">近期咨询</span>
                <ol>
                    <li v-for="(item, index) in newsList" :key="index" @click="$router.push(`/news/${item.id}`)">{{item.title}}</li>
                </ol>
            </div>
        </div>

        

    </div>
</template>

<script>
import { newsList } from './data'

export default {
    name: 'NewsDetail',
    data(){
        return {
            newsList
        }
    },
    computed: {
        detail(){
            return this.newsList[this.$route.params.id]
        }
    },
    created(){
        // console.log(this.$route.params.id)
    },
    methods: {
        removeHtmlStyle(html) {
            var rel = /style\s*?=\s*?(['"])[\s\S]*?\1/g;
            var newHtml = "";
            if (html) {
                newHtml = html.replace(rel, "");
            }
            return newHtml;
        },

    }
}
</script>

<style lang="less" scoped>
.news_detail {
    width: 1920px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;

    .banner {
        width: 100%;
        height: 500px;
        background: url('../../assets/image/news/banner.png');
        background-size: 100% 100%;
        position: relative;

        .shadow {
            position: absolute;
            bottom: 0;
            left: 129px;
            width: 755px;
            height: 362px;
            background: rgba(0, 0, 0, 0.4);
            border-radius: 30px 30px 0px 0px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            letter-spacing: 2px;
            color: #FFFFFF;

            .tit {
                font-size: 40px;
                margin: 65px 0 0 61px;
            }

            .dec {
                font-size: 24px;
                margin: 0 20px 136px 61px;
                line-height: 30px;
                font-weight: 300;
            }

            .tel {
                font-size: 30px;
                margin: 0 0 65px 61px;
            }
        }
    }

    .content {
        width: calc(100% - 240px * 2);
        padding: 110px 240px 40px 240px;
        display: flex;
        border-bottom: 1px solid #C4C4C4;
        margin-bottom: 120px;

        .left {
            flex: 1;
            display: flex;
            flex-direction: column;
            margin-right: 100px;

            .breadcrumb {
                font-size: 16px;
                line-height: 16px;
                display: flex;
                align-items: center;
                color: #333333;
                margin-bottom: 65px;

                a {
                    text-decoration: none;
                    color: #333333;

                    &.active {
                        color: #4870FF;
                    }
                }

                span {
                    display: inline-block;
                    margin: 0 8px;
                }
            }

            .tit {
                font-size: 40px;
                line-height: 40px;
                display: block;
                color: #333333;
                margin-bottom: 44px;
            }

            .dec {
                font-size: 22px;
                line-height: 22px;
                color: #999999;
                margin-bottom: 110px;
            }

            .html_wrap {
                width: 100%;
                font-size: 18px;
                color: #666666;

                /deep/.editor {
                    font-size: 18px !important;
                    color: #666666 !important;
                }

                /deep/p {
                    font-size: 18px;
                    color: #666666;
                }

                /deep/span {
                    font-size: 18px !important;
                    color: #666666 !important;
                    line-height: 30px !important;
                }
            }

            .pagination {
                display: flex;
                align-items: center;
                justify-content: space-between;
                font-size: 16px;
                line-height: 16px;
                color: #666666;

                span {
                    cursor: pointer;
                    display: flex;
                    align-items: center;

                    i {
                        width: 16px;
                        height: 16px;
                        border-radius: 50%;
                        background: #C4C4C4;
                        color: #fff;
                        font-size: 6px;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        margin: 0 12px;
                    }
                }
            }
        }

        .right {
            width: 380px;
            display: flex;
            flex-direction: column;

            .tit {
                font-size: 22px;
                line-height: 22px;
                color: #666666;
                display: block;
                margin-bottom: 45px;
            }

            ol {
                list-style: disc;
                padding-left: 20px;
                font-size: 18px;
                line-height: 27px;
                color: #999999;

                li {
                    cursor: pointer;
                    margin-bottom: 24px;
                }
            }
        }
    }
}</style>